//
//  UIImage+BLImage.m
//  03 - 彩票 0.14
//
//  Created by 大L君的无敌战舰 on 16/3/27.
//  Copyright © 2016年 bigL.com. All rights reserved.
//

#import "UIImage+BLImage.h"

@implementation UIImage (BLImage)

//返回无渲染的image
+ (UIImage *)imageWithModeOfOriginalImageNamed:(NSString *)imageNamed
{
    UIImage *image = [UIImage imageNamed:imageNamed];
    image          = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    return image;
}

//返回无渲染的image
- (UIImage *)imageWithModeOfOriginalImage:(UIImage *)image
{
    image          = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    return image;
}



//自动判断图片后缀,返回image
+ (UIImage *)imageIncertitudeImageName:(NSString *)imageNamed
{
    UIImage * image = [UIImage imageNamed:imageNamed];
    
    if (!image){
        //遍历格式字典
        NSArray * imageTypeArray =[[NSArray alloc] initWithObjects:@".JPG",@".PNG",@".BMP",@".JPEG",@".GIF",nil];
        //判断格式存在正确?
        for (NSInteger i = 0; i<imageTypeArray.count; i++){
            NSString * imageTypeStr = imageTypeArray[i];
            NSString * imageStr     = [imageNamed stringByAppendingString:imageTypeStr];
            UIImage * imageTemp     = [UIImage imageNamed:imageStr];
            if (imageTemp){
                //返回图片
                return imageTemp;
            }
        }
        //不在遍历字典内的类型
        NSLog(@"error : 图片格式未知");
    }
    return image;
}



@end
